home *** CD-ROM | disk | FTP | other *** search
- /************************************************************/
- /* */
- /* CStarterPane Code from Chapter Six of */
- /* */
- /* *** The Macintosh Programming Primer *** */
- /* */
- /* Copyright 1990, Dave Mark */
- /* */
- /* This program demonstrates specific Mac programming */
- /* techniques. */
- /* */
- /************************************************************/
-
- #include "CStarterPane.h"
- #include "CDragPane.h"
- #include "CMouse.h"
-
-
- /**************************************** IStarterPane */
-
- void CStarterPane::IStarterPane( CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing )
- {
- CPanorama::IPanorama( anEnclosure, aSupervisor,
- aWidth, aHeight,
- aHEncl, aVEncl,
- aHSizing, aVSizing );
-
- GetDateTime( (unsigned long *)&randSeed );
-
- SetWantsClicks( TRUE );
- }
-
-
- /******************************** DoClick *********/
-
- void CStarterPane::DoClick( Point hitPt, short modifierKeys, long when )
- {
- int width, height, patNum;
- CDragPane *myDragPane;
-
- width = Randomize( MAX_PANE_SIZE );
- height = Randomize( MAX_PANE_SIZE );
- patNum = Randomize( NUM_PATS );
-
- myDragPane = new( CDragPane );
- myDragPane->IDragPane( hitPt, height, width,
- patNum, this, this );
- }
-
-
- /******************************** AdjustCursor *********/
-
- void CStarterPane::AdjustCursor( Point where, RgnHandle mouseRgn )
- {
- SetCursor( *GetCursor( plusCursor ) );
- }
-
-
- /******************************** DoDrag *********/
-
- void CStarterPane::DoDrag( int objWidth, int objHeight,
- Point hitPt, Rect startLocation, Rect *endLocation )
- {
- CMouse *aMouseTask;
- LongRect boundsRect;
- Point p;
- LongPt longP;
-
- gIsScrolling = TRUE;
-
- boundsRect = bounds;
-
- aMouseTask = new( CMouse );
-
- aMouseTask->IMouse( NO_UNDO_STRING, objWidth,
- objHeight, hitPt, startLocation, this );
-
- Prepare();
-
- GetMouse( &p );
- QDToLongPt( p, &longP );
- TrackMouse( aMouseTask, &longP, &boundsRect );
-
- gIsScrolling = FALSE;
-
- aMouseTask->GetLocation(endLocation); /* Update endLocation */
-
- Refresh();
- }
-
-
- /******************************** Randomize *********/
-
- Randomize( int range )
- {
- long rawResult;
-
- rawResult = Random();
- if ( rawResult < 0 ) rawResult *= -1;
- return( (rawResult * range) / 32768 );
- }